home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Network Support Library
/
RoseWare - Network Support Library.iso
/
apidev
/
lastdr.arc
/
LASTDRIV.C
next >
Wrap
C/C++ Source or Header
|
1989-02-16
|
3KB
|
77 lines
/* LASTDRIV.C
** Version 1.0a
** Date: Jan 25 1988
** By: Mike Watkins
** Modified : Feb 15 1989
**
** Purpose: uses DOS function calls 14, 25 to determine what the current
** drive is and increment default drive to the lastdrive found.
**
** Uses: useful to determine that last valid network drive after
** logging off a network. Something like this batch file
** - call it NET.BAT
**
** Example: @echo off (use the @ on DOS 3.3 to hide all)
** ipx
** net3
** lastdriv
** login
** l:
** menu [filename]
**
**/
/* This program, however useless it is, is hearby released to the
** public domain - Mike Watkins 02/15/89
*/
#include <dos.h>
union REGS inregs, outregs;
#define DosCall 0x21 /* interupt 21H (dec 33) universal DOS functions */
#define DosSetDrive 0x0e /* function 14 select current drive */
#define DosGetDrive 0x19 /* function 25 report current drive */
#define DosWriteTTY 0x09 /* dos write tty function */
int drivenum = 0; /* last drive number */
main()
{ /* let 'em know were here! */
WriteTTY("\n\rLastdriv Version 1.0a (C) 1988 Software Suprizes\n\r$");
inregs.h.ah = DosGetDrive; /* first find out current drive */
int86(DosCall, &inregs, &outregs); /* outregs.h.al now equals current drive */
drivenum = outregs.h.al;
inregs.h.ah = DosSetDrive;
inregs.h.dl = drivenum;
int86(DosCall, &inregs, &outregs); /* outregs.h.al now = drive count */
drivenum = outregs.h.al;
/* don't trust # of drives reported by last count. loop up to that */
LoopDrives(); /* maximum, as some configurations leave holes in sequence */
exit(0);
/* DOS won't allow you to set drive that isn't there anyways */
} /* end of main */
LoopDrives()
{
int i;
for (i=0; i <= drivenum - 1; i++){
inregs.h.ah = DosSetDrive;
inregs.h.dl = (i); /* drive numbering starts as A=0 B=1 ... */
int86(DosCall, &inregs, &outregs);
}
}
WriteTTY(string)
char *string;
{
inregs.x.dx = string; /* use DosWriteTTY to print - smaller code than printf */
inregs.h.ah = DosWriteTTY;
int86(DosCall, &inregs, &outregs);
}